<template>
  <div class="app-container">
    <el-container style="height: 100vh;">
      <!-- 左侧文件上传区域 -->
      <el-aside width="380px" class="left-panel">
        <div class="panel-header">
          <el-icon :size="24" style="margin-right: 8px;">
            <Folder />
          </el-icon>
          <span class="panel-title">文件列表</span>
        </div>
        <FileUploader @select-file="handleSelectFile" />
      </el-aside>

      <!-- 右侧文件预览区域 -->
      <el-main class="right-panel">
        <div class="panel-header">
          <el-icon :size="24" style="margin-right: 8px;">
            <View />
          </el-icon>
          <span class="panel-title">文件预览</span>
          <div class="file-info" v-if="currentFile">
            <el-tag type="info" size="small">{{ currentFile.name }}</el-tag>
          </div>
        </div>
        <FilePreview :file="currentFile" />
      </el-main>
    </el-container>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import FileUploader from './components/FileUploader.vue'
import FilePreview from './components/FilePreview.vue'
import { Folder, View } from '@element-plus/icons-vue'

// 当前选中的文件
const currentFile = ref(null)

// 处理文件选择
const handleSelectFile = (file) => {
  currentFile.value = file
}
</script>

<style scoped>
.app-container {
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.left-panel {
  background: #ffffff;
  border-right: 1px solid #e4e7ed;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.right-panel {
  background: #f5f7fa;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 16px 20px;
  background: #ffffff;
  border-bottom: 1px solid #e4e7ed;
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 16px;
  color: #303133;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.panel-title {
  flex: 1;
}

.file-info {
  margin-left: 12px;
}

.el-container {
  overflow: hidden;
}
</style>

